<?php
header("Content-Type: application/json; charset=UTF-8");
// header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");

// Replace these with your own database credentials
require_once 'db_config.php';


// Get fish ID from request
$fish_id = isset($_GET['id']) ? intval($_GET['id']) : 0;

// SQL query to get fish details by ID
$sql = "SELECT * FROM vuemodel WHERE id = $fish_id";

// Execute query and prepare response
$result = $conn->query($sql);
$response = array();

if ($result->num_rows > 0) {
    $response["data"] = $result->fetch_assoc();
    $response["success"] = true;
} else {
    $response["success"] = false;
    $response["message"] = "No fish found with the given ID.";
}

// Close connection
$conn->close();

// Return JSON response
echo json_encode($response);
?>
